//
//  DetailViewController.m
//  uplife
//
//  Created by ZhangCheng on 2018/12/25.
//  Copyright © 2018年 ZhangCheng. All rights reserved.
//

#import "DetailViewController.h"
//#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相关所有的头文件
//#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件


@interface DetailViewController ()<UIGestureRecognizerDelegate>{
//    BMKMapView *_mapView;
}
@property (weak, nonatomic) IBOutlet UILabel *gouRuJiaGeLabel;
@property (weak, nonatomic) IBOutlet UILabel *biaoMianHuiBaoLvLabel;
@property (weak, nonatomic) IBOutlet UILabel *jianZhuNianFenLabel;
@property (weak, nonatomic) IBOutlet UILabel *gouZaoLabel;
@property (weak, nonatomic) IBOutlet UILabel *louCengLabel;
@property (weak, nonatomic) IBOutlet UILabel *zhuanYouMianJiLabel;
@property (weak, nonatomic) IBOutlet UILabel *guDouShuiLabel;
@property (weak, nonatomic) IBOutlet UILabel *guanLiFeiLabel;
@property (weak, nonatomic) IBOutlet UILabel *xiuShanJinLabel;
@property (weak, nonatomic) IBOutlet UILabel *huoZaiXianLabel;
@property (weak, nonatomic) IBOutlet UILabel *diZhiLabel;

@property(nonatomic,strong)IBOutlet UIView *mapViewSuperView;

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.gouRuJiaGeLabel.text = [NSString stringWithFormat:@"%@(%@%@)",self.fatherViewController.dataDic[@"JbuyPrice"],[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"buyPrice"]];
    self.gouRuJiaGeLabel.text = [NSString stringWithFormat:@"%@万円",FORMAT_PRICE(self.fatherViewController.dataDic[@"JbuyPrice"])];
//    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:self.gouRuJiaGeLabel.text attributes:@{NSFontAttributeName: self.gouRuJiaGeLabel.font,NSForegroundColorAttributeName: self.gouRuJiaGeLabel.textColor}];
//
//    [string addAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:136/255.0 green:138/255.0 blue:143/255.0 alpha:1.0]} range:[self.gouRuJiaGeLabel.text rangeOfString:[NSString stringWithFormat:@"(%@%@)",[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"buyPrice"]]]];
//    self.gouRuJiaGeLabel.attributedText = string;
    
    NSNumber *returnRate = self.fatherViewController.dataDic[@"returnRate"];
    self.biaoMianHuiBaoLvLabel.text = [NSString stringWithFormat:@"%.0f%%",returnRate.floatValue];
    self.jianZhuNianFenLabel.text = [NSString stringWithFormat:@"%@",self.fatherViewController.dataDic[@"buildDate"]];
    self.gouZaoLabel.text = [NSString stringWithFormat:@"%@",self.fatherViewController.dataDic[@"structureValue"]];
    self.louCengLabel.text = [NSString stringWithFormat:@"%@层",self.fatherViewController.dataDic[@"floor"]];
    self.zhuanYouMianJiLabel.text = [NSString stringWithFormat:@"%@㎡",self.fatherViewController.dataDic[@"area"]];
    
//    self.guDouShuiLabel.text = [NSString stringWithFormat:@"%@(%@%@)",self.fatherViewController.dataDic[@"JgdTax"],[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"gdTax"]];
    self.guDouShuiLabel.text = [NSString stringWithFormat:@"%@円",FORMAT_PRICE(self.fatherViewController.dataDic[@"JgdTax"])];
//    string = [[NSMutableAttributedString alloc] initWithString:self.guDouShuiLabel.text attributes:@{NSFontAttributeName: self.guDouShuiLabel.font,NSForegroundColorAttributeName: self.guDouShuiLabel.textColor}];
    
//    [string addAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:136/255.0 green:138/255.0 blue:143/255.0 alpha:1.0]} range:[self.guDouShuiLabel.text rangeOfString:[NSString stringWithFormat:@"(%@%@)",[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"gdTax"]]]];
//    self.guDouShuiLabel.attributedText = string;
    
//    self.guanLiFeiLabel.text = [NSString stringWithFormat:@"%@(%@%@)",self.fatherViewController.dataDic[@"JmanageCost"],[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"manageCost"]];
    self.guanLiFeiLabel.text = [NSString stringWithFormat:@"%@円",FORMAT_PRICE(self.fatherViewController.dataDic[@"JmanageCost"])];
//    string = [[NSMutableAttributedString alloc] initWithString:self.guanLiFeiLabel.text attributes:@{NSFontAttributeName: self.guanLiFeiLabel.font,NSForegroundColorAttributeName: self.guanLiFeiLabel.textColor}];
//
//    [string addAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:136/255.0 green:138/255.0 blue:143/255.0 alpha:1.0]} range:[self.guanLiFeiLabel.text rangeOfString:[NSString stringWithFormat:@"(%@%@)",[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"manageCost"]]]];
//    self.guanLiFeiLabel.attributedText = string;
    
//    self.xiuShanJinLabel.text = [NSString stringWithFormat:@"%@(%@%@)",self.fatherViewController.dataDic[@"JfixCost"],[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"fixCost"]];
    self.xiuShanJinLabel.text = [NSString stringWithFormat:@"%@円",FORMAT_PRICE(self.fatherViewController.dataDic[@"JfixCost"])];
//    string = [[NSMutableAttributedString alloc] initWithString:self.xiuShanJinLabel.text attributes:@{NSFontAttributeName: self.xiuShanJinLabel.font,NSForegroundColorAttributeName: self.xiuShanJinLabel.textColor}];
//
//    [string addAttributes:@{NSForegroundColorAttributeName: [UIColor colorWithRed:136/255.0 green:138/255.0 blue:143/255.0 alpha:1.0]} range:[self.xiuShanJinLabel.text rangeOfString:[NSString stringWithFormat:@"(%@%@)",[ZCTool sharedInstance].currentSelectedHuoBiDic[@"code"],self.fatherViewController.dataDic[@"fixCost"]]]];
//    self.xiuShanJinLabel.attributedText = string;
    
    self.huoZaiXianLabel.text = [NSString stringWithFormat:@"%@",self.fatherViewController.dataDic[@"insure"]];
    self.diZhiLabel.text = [NSString stringWithFormat:@"%@",self.fatherViewController.dataDic[@"buildingAddress"]];
    
//    _mapView = [[BMKMapView alloc]initWithFrame:CGRectMake(self.mapViewSuperView.frame.origin.x, self.mapViewSuperView.frame.origin.y, [UIScreen mainScreen].bounds.size.width, self.mapViewSuperView.frame.size.height)];
//    _mapView.delegate = self;
//    _mapView.rotateEnabled = NO;
//    _mapView.clipsToBounds = YES;
////    _mapView.zoomEnabled
////    _mapView.gesturesEnabled=YES;
//    [self.mapViewSuperView addSubview:_mapView];
    
    UIGestureRecognizer *gestur = [[UIGestureRecognizer alloc]init];
    gestur.delegate=self;
    [self.fatherViewController.scrollView addGestureRecognizer:gestur];
    
//    UIGestureRecognizer *gestur2 = [[UIGestureRecognizer alloc]init];
//    gestur2.delegate=self;
//    [self.tableView addGestureRecognizer:gestur2];
    
    
//    UIGestureRecognizer *gestur1 = [[UIGestureRecognizer alloc]init];
//    gestur1.delegate=self;
//    [_mapView addGestureRecognizer:gestur1];
    
    
    
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    
//    if ([gestureRecognizer.view isKindOfClass:[BMKMapView class]]) {
//        self.fatherViewController.scrollView.scrollEnabled=NO;
//        self.tableView.scrollEnabled = NO;
//    }else{
        self.fatherViewController.scrollView.scrollEnabled=YES;
        self.tableView.scrollEnabled = YES;
//    }
    
    return NO;
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
//    [_mapView viewWillAppear];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
//    [_mapView viewWillDisappear];
}

-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
//    BMKPointAnnotation* annotation = [[BMKPointAnnotation alloc]init];
//    annotation.coordinate = CLLocationCoordinate2DMake(((NSNumber*)self.fatherViewController.dataDic[@"latitude"]).doubleValue, ((NSNumber*)self.fatherViewController.dataDic[@"longitude"]).doubleValue);
//    annotation.title = self.fatherViewController.dataDic[@"buildingName"];
//    [_mapView addAnnotation:annotation];
//
//    [_mapView setRegion:BMKCoordinateRegionMake(annotation.coordinate, BMKCoordinateSpanMake(0.05, 0.05))];
}
//- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation
//{
//    if ([annotation isKindOfClass:[BMKPointAnnotation class]]) {
//        static NSString *pointReuseIndentifier = @"pointReuseIndentifier";
//        BMKPinAnnotationView*annotationView = (BMKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndentifier];
//        if (annotationView == nil) {
//            annotationView = [[BMKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndentifier];
//        }
//        annotationView.pinColor = BMKPinAnnotationColorPurple;
//        annotationView.canShowCallout= YES;      //设置气泡可以弹出，默认为NO
//        annotationView.clipsToBounds = YES;
////        annotationView.animatesDrop=YES;         //设置标注动画显示，默认为NO
////        annotationView.draggable = YES;          //设置标注可以拖动，默认为NO
//        return annotationView;
//    }
//    return nil;
//}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
